$(function(){
	//边换主题颜色
	var model=localStorage.model;
	if(model==1){
		$('#protectwetlandHomePage').css('background','#535a7e');
	}else if(model==2){
		$('#protectwetlandHomePage').css('background','#129b63');
	}	
});



$.ajax({
	  url:'../wetlandManager/protectwetlandHomePageInfoForXJ', 
	  type:'POST', 
	  async:false,
	  success:function(data){			
	  	for(var i=0;i<data.length;i++){		  		
	  		if(data[i].picturetype=='bar1'){
	  		//保护主体面积图表设置
	  			 var myChart2 = echarts.init(document.getElementById('protection_class'));
	  			var option2 = {
	  				 tooltip : {
	  						trigger: 'axis',
	  						axisPointer : {            // 坐标轴指示器，坐标轴触发有效
	  							type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	  						},
	  				        formatter: function(prams) {
	  				        	var datas='';
	  				        	for(var i=0;i<prams.length;i++){
	  				        		var name=prams[i].seriesName.split('（')[0];
	  				        		var data=name+':'+prams[i].data+'公顷</br>';
	  				        		datas+=data;
	  				        	}
	  				        	return datas;
	  				        }
	  			    },
	  			    legend: {
	  			    	 data:[data[i].names[1],data[i].names[4],data[i].names[0]+'    ',data[i].names[3],data[i].names[2]],
					        textStyle:{
					        	color:'#fff',
					        	fontSize:12
					        }
	  			    },
	  			    grid: {
	  			        left: '3%',
	  			        right: '4%',
	  			        bottom: '3%',
	  			        containLabel: true
	  			    },
	  			    yAxis:  {
	  			        type: 'value',
	  					splitLine:{
	  						show: true,
	  						 lineStyle:{
	  									type:'dashed'
	  			                    },
	  						},
	  					axisLine: {
	  			               show: true,
	  			               lineStyle:{
	  			               fontSize:'20px',
	  			               color:'white'
	  			               }
	  			          }
	  				  
	  			    },
	  			    xAxis: {
	  			        type: 'category', 
	  					axisLine: {
	  			                    show: true,
	  			                    lineStyle:{
	  			                        fontSize:'20px',
	  			                        color:'white'
	  			                    }
	  			            },
	  					    axisLabel:{
	  								 //X轴刻度配置
	  								interval:0,//0：表示全部显示不间隔；auto:表示自动根据刻度个数和宽度自动设置间隔个数
	  								rotate:60,
	  								margin:2
	  								},	
	  						data:data[i].xaxis,
	  			    },
	  			  grid: {   	    
				        left: '3%',
				        right: '4%',
				        bottom: '6%',
				        top:'30%',
				        containLabel: true
				    },
	  			    series: [
	  			        {
	  			            name: data[i].names[0]+'    ',
	  			            type: 'bar',
	  			            stack: '总量',
	  			            barWidth : 8,
	  			             itemStyle:{
	  			                normal: {
	  			                    show: true,
	  			                    color: '#3d80df'
	  			                }
	  			            },
	  			            data: data[i].rawdata[0]
	  			        },
	  			        {
	  			            name: data[i].names[1],
	  			            type: 'bar',
	  			            stack: '总量',
	  			             itemStyle:{
	  			                normal: {
	  			                    show: true,
	  			                    color: '#7cb7ea'
	  			                }
	  			            },
	  			            data: data[i].rawdata[1]
	  			        },
	  			        {
	  			            name: data[i].names[2],
	  			            type: 'bar',
	  			            stack: '总量',
	  			            itemStyle:{
	  			                normal: {
	  			                    show: true,
	  			                    color: '#54a1a3'
	  			                }
	  			            },       
	  			            data: data[i].rawdata[2]
	  			        },
	  			        {
	  			            name: data[i].names[3],
	  			            type: 'bar',
	  			            stack: '总量',
	  			             itemStyle:{
	  			                normal: {
	  			                    show: true,
	  			                    color: '#9dbcdd'
	  			                }
	  			            },          
	  			            data: data[i].rawdata[3]
	  			        },
	  			        {
	  			            name: data[i].names[4],
	  			            type: 'bar',
	  			            stack: '总量',
	  			             itemStyle:{
	  			                normal: {
	  			                    show: true,
	  			                    color: '#a8cb89'
	  			                }
	  			            },
	  			            data: data[i].rawdata[4] 
	  			        }
	  			    ]
	  		};
	  			 myChart2.setOption(option2);
	  		}else if(data[i].picturetype=='line1'){
	  		//保护主体年增长趋势
	  		  var myChart3= echarts.init(document.getElementById('protection_add'));
	  		 var option3 = {
	  				 tooltip: {
	  				        trigger: 'axis',
	  				        axisPointer: {
	  				            lineStyle: {
	  				                color: '#57617B'
	  				            }
	  				        }
	  				    },
	  				    legend: {
	  				       data:data[i].names ,
	  				       textStyle:{
								color:'white',
								fontsize:'25px'
							}
	  				    },
	  				    grid: {
	  				        left: '3%',
	  				        right: '4%',
	  				        bottom: '3%',
	  				        containLabel: true
	  				    },
	  				    xAxis: [{
	  				        type: 'category',
	  				        boundaryGap: false,
	  						axisLine: {
	  		                    show: true,
	  		                    lineStyle:{
	  		                        fontSize:'20px',
	  		                        color:'white'
	  		                    }
	  		            },
	  				        data: data[i].xaxis
	  				    }],
	  				    yAxis: [{
	  				        type: 'value',
	  				        axisTick: {
	  				            show: false
	  				        },
	  				        axisLabel: {
	  				            left: 15,
	  				            textStyle: {
	  				                fontSize: 14
	  				            }
	  				        },
	  						axisLine: {
	  		                    show: true,
	  		                    left: 20,
	  		                    lineStyle:{
	  		                        fontSize:'20px',
	  		                        color:'white'
	  		                    }
	  		            },
	  				        splitLine:{
	  							show: true,
	  							 lineStyle:{
	  										type:'dashed'
	  				                    },
	  							}
	  				    }],
	  				    series: [{
	  				        name: data[i].names[0],
	  				        type: 'line',	
	  				        itemStyle: {
	  				            normal: {
	  				                color: '#a8cb89'
	  				            }
	  				        },
	  				        data: data[i].rawdata[0]
	  				    }, {
	  				        name: data[i].names[1],
	  				        type: 'line',			       
	  				        itemStyle: {
	  				            normal: {
	  				                color: '#9bdcdd'
	  				            }
	  				        },
	  				        data: data[i].rawdata[1]
	  				    }, {
	  				        name: data[i].names[2],
	  				        type: 'line',	     
	  				        itemStyle: {
	  				            normal: {
	  				                color: '#54a1a3'
	  				            }
	  				        },
	  				        data: data[i].rawdata[2]
	  				    }, {
	  				        name: data[i].names[3],
	  				        type: 'line',		      
	  				        itemStyle: {
	  				            normal: {
	  				                color: '#7cb7ea'
	  				            }
	  				        },
	  				        data: data[i].rawdata[3]
	  				    },{
	  				        name: data[i].names[4],
	  				        type: 'line',		        
	  				        itemStyle: {
	  				            normal: {
	  				                color: '#3d80bf'
	  				            }
	  				        },
	  				        data: data[i].rawdata[4]
	  				    },  ]
	  				};
	  		 myChart3.setOption(option3);
	  		}else if(data[i].picturetype=='line2'){
	  			 //湿地面积排名
	  		  var myChart4= echarts.init(document.getElementById('protection_first'));
	  		 var option4 = {			   
	  				 tooltip: {				 
	  					 trigger: 'axis'
	  				    },

	  				    grid: {
	  				        left: '3%',
	  				        right: '4%',
	  				        bottom: '3%',
	  				        containLabel: true
	  				    },
	  				    xAxis: [{
	  				        type: 'category',
	  				        show:true,
	  				        boundaryGap: true,
	  						axisLine: {
	  		                    lineStyle:{
	  		                        fontSize:'20px',
	  		                        color:'white'
	  		                    }
	  		            },
	  				        data: data[i].xaxis
	  				    }],
	  				    yAxis: [{
	  				        type: 'value',
	  				        axisTick: {
	  				            show: false
	  				        },
	  						axisLine: {
	  		                    show: true,
	  		                    lineStyle:{
	  		                        fontSize:'20px',
	  		                        color:'white'
	  		                    }
	  		            },
	  						splitLine:{
	  							show: true,
	  							 lineStyle:{
	  										type:'dashed'
	  				                    },
	  							},
	  				        axisLabel: {
	  				            margin: 10,
	  				            textStyle: {
	  				                fontSize: 14
	  				            }
	  				        },
	  				   
	  				    }],
	  				    series: [{
	  				        name: '(面积)',		
	  				        type: 'line',
	  				        symbol: 'circle',
	  				        areaStyle: {
	  				            normal: {
	  				                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                    offset: 1,
	  				                    color: 'rgba(61,128,223,0)'
	  				                }, {
	  				                    offset: 0,
	  				                    color: 'rgba(84,161,163, 1)'
	  				                }], false),
	  				                shadowColor: 'rgba(0, 0, 0, 0.1)',
	  				                shadowBlur: 10
	  				            },
	  				        },
	  				      itemStyle: {
	  				            normal: {
	  				                color: '#2e87c9'
	  				            }
	  				        },
	  				          data: data[i].rawdata[0],
	  						 label: {
	  				            normal: {
	  				                show: false,
	  				                position: 'top' //值显示
	  				            }
	  				        }		
	  				    }  ]
	  				};
	  		 myChart4.setOption(option4);
	  		}else if(data[i].picturetype=='保护形式'){
	  			var gjsd=[];
	  			var gjzr=[];
	  			var sdbh=[];
	  			var sjsd=[];
	  			var sjzr=[];
	  			for(var key in data[i]){
	  				if(key=='国家湿地公园或试点'){
	  					gjsd=data[i][key];
	  				}else if(key=='国家级自然保护区'){
	  					gjzr=data[i][key];
	  				}else if(key=='湿地保护小区'){
	  					sdbh=data[i][key];
	  				}else if(key=='省级湿地公园'){
	  					sjsd=data[i][key];
	  				}else if(key=='省级自然保护区'){
	  					sjzr=data[i][key];
	  				}
	  			}
	  			console.log(gjsd);
	  			//保护形式图表设置	
	  			var myChart = echarts.init(document.getElementById('protection_grade'));
	  				
	  			option = {
	  				    series: [
	  				             {
	  				               name: '国家级自然保护区',
	  				               type: 'pie',
	  				               radius: ['43%', '48%'],
	  				               center: ['30%', '27%'],
	  				               startAngle: 225,
	  				               color: [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                   offset: 0,
	  				                   color: '#54a1a3'
	  				               }, {
	  				                   offset: 1,
	  				                   color: '#54a1a3'
	  				               }]), "transparent"],
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                    name: '国家级自然保护区',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '国家级自然\n保护区', 
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13
	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 75,
	  				                    name: '国家级自然保护区',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+gjzr[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15
	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+gjzr[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }
	  				               ]
	  				           },
	  				           {
	  				               name: '省级自然保护区',
	  				               type: 'pie',
	  				               radius: ['43%', '48%'],
	  				               center: ['70%', '27%'],
	  				               startAngle: 225,
	  				               color: [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                   offset: 0,
	  				                   color: '#54a1a3'
	  				               }, {
	  				                   offset: 1,
	  				                   color: '#54a1a3'
	  				               }]), "transparent"],
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }  
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                    name: '省级自然保护区',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '省级自然保护区',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 75,
	  				                    name: '省级自然保护区',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+sjzr[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+sjzr[1]+" 公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '国家湿地公园或试点',
	  				               type: 'pie',
	  				               radius: ['43%', '48%'],
	  				               center: ['16%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '国家湿地公园\n或试点',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13
	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '国家湿地公园或试点',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+gjsd[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+gjsd[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '省级湿地公园',
	  				               type: 'pie',
	  				               radius: ['43%', '48%'],
	  				               center: ['50%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '省级湿地公园  ',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '省级湿地公园',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+sjsd[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+sjsd[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '湿地保护小区',
	  				               type: 'pie',
	  				               radius: ['43%', '48%'],
	  				               center: ['84%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '湿地保护小区  ',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '湿地保护小区',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+sdbh[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+sdbh[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				       ]
	  			};
	  			 myChart.setOption(option);
	  		}else if(data[i].picturetype=='保护级别'){
	  		  var ybsd=[];
	  		  var gjzy=[];
	  		  var gjsd=[];
	  		  var sjzy=[];
	  		  var sjsd=[];
	  		for(var key in data[i]){
				if(key=='一般湿地'){
					ybsd=data[i][key];
				}else if(key=='国家重要湿地'){
					gjzy=data[i][key];
				}else if(key=='国际重要湿地'){
					gjsd=data[i][key];
				}else if(key=='市级重要湿地'){
					sjzy=data[i][key];
				}else if(key=='省级重要湿地'){
					sjsd=data[i][key];
				}
			}
	  			 //生态物种柱状图
	  		  var myChart5= echarts.init(document.getElementById('protection_area'));
	  		  var option5= {
	  				  series: [
	  				             {
	  				               name: '国际重要湿地',
	  				               type: 'pie',
	  				               radius: ['40%', '45%'],
	  				               center: ['30%', '25%'],
	  				               startAngle: 225,
	  				               color: [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                   offset: 0,
	  				                   color: '#54a1a3'
	  				               }, {
	  				                   offset: 1,
	  				                   color: '#54a1a3'
	  				               }]), "transparent"],
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                    name: '国际重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '国际重要湿地',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13
	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 75,
	  				                    name: '国际重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+gjsd[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15
	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+gjsd[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }
	  				               ]
	  				           },
	  				           {
	  				               name: '国家重要湿地',
	  				               type: 'pie',
	  				               radius: ['40%', '45%'],
	  				               center: ['70%', '25%'],
	  				               startAngle: 225,
	  				               color: [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                   offset: 0,
	  				                   color: '#54a1a3'
	  				               }, {
	  				                   offset: 1,
	  				                   color: '#54a1a3'
	  				               }]), "transparent"],
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                    name: '国家重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '国家重要湿地',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 75,
	  				                    name: '国家重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+gjzy[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+gjzy[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '省级重要湿地',
	  				               type: 'pie',
	  				               radius: ['40%', '45%'],
	  				               center: ['16%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '省级重要湿地',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '省级重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+sjsd[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+sjsd[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '市级重要湿地',
	  				               type: 'pie',
	  				               radius: ['40%', '45%'],
	  				               center: ['50%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '市级重要湿地 ',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '市级重要湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+sjzy[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+sjzy[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				            {
	  				               name: '一般湿地',
	  				               type: 'pie',
	  				               radius: ['40%', '45%'],
	  				               center: ['84%', '70%'],
	  				               startAngle: 225,
	  				               labelLine: {
	  				                   normal: {
	  				                       show: false
	  				                   }
	  				               },
	  				               label: {
	  				                       normal: {
	  				                           position: 'center'
	  				                       }
	  				                   },
	  				               data: [{
	  				                   value: 0,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: '一般湿地 ',
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 13

	  				                               }
	  				                           }
	  				                       }
	  				               },{
	  				                   value: 75,
	  				                   "itemStyle": {
	  				                       "normal": {
	  				                           "color": new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                               "offset": 0,
	  				                               "color": '#54a1a3'
	  				                           }, {
	  				                               "offset": 1,
	  				                               "color": '#54a1a3'
	  				                           }]),
	  				                       }
	  				                   },
	  				                    name: '一般湿地',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n"+ybsd[0]+"个",
	  				                               textStyle: {
	  				                                   color: '#f29b76',
	  				                                   fontSize: 15

	  				                               }
	  				                           }
	  				                       }
	  				               }, {
	  				                   value: 25,
	  				                   name: '%',
	  				                       label: {
	  				                           normal: {
	  				                               formatter: "\n共"+ybsd[1]+"公顷",
	  				                               textStyle: {
	  				                                   color: '#9bdcdd',
	  				                                   fontSize: 12

	  				                               }
	  				                           }
	  				                       }
	  				               }]
	  				           },
	  				       ]
	  				};
	  		  myChart5.setOption(option5);
	  		}else if(data[i].picturetype=='citycounts'){
	  			$('#species').empty();
	  			var num=1;
				for(var j=0;j<data[i].names.length;j++){
	  				$('#species').append("<div style='width: 80%;height:40px;margin-left:10%; margin-top:20px;background-color:#247b8e;'>"
	  				+"<span style='color: #f29b76;margin-left:30px;position: absolute;margin-top: 10px;'>NO."+num+"</span>"
	  				+"<span style='color: #fff;width:70px;margin-left:90px;position: absolute;margin-top: 10px;'>"+data[i].names[j]+"</span>"
	  				+"<span style='color: #fff;width:50px;margin-left:300px;position: absolute;margin-top: 10px;'>"+data[i].counts[j]+"个</span>");
	  				num++;
	  			}	
	  		}else if(data[i].picturetype=='cityareas'){
	  			$('#areas').empty();
	  			var num=1;
				for(var j=0;j<data[i].names.length;j++){
	  				$('#areas').append("<div style='width: 80%;height:40px;margin-left:10%; margin-top:20px;background-color:#247b8e;'>"
	  				+"<span style='color: #f29b76;margin-left:30px;position: absolute;margin-top: 10px;'>NO."+num+"</span>"
	  				+"<span style='color: #fff;width:70px;margin-left:90px;position: absolute;margin-top: 10px;'>"+data[i].names[j]+"</span>"
	  				+"<span style='color: #fff;width:120px;margin-left:250px;position: absolute;margin-top: 10px;'>"+data[i].areas[j]+"公顷</span>");
	  				num++;
	  			}	
	  		}
	  	}
	  }	
});


//地图
var sites =new Array();
//gis地图
require(["esri/Basemap"], function(Basemap) { 
		
});

require([
     	"esri/Map",
     	"esri/views/MapView",
     	"esri/views/ui/UI", 
     	"esri/layers/FeatureLayer",
     	"esri/Graphic",
     	"esri/widgets/BasemapToggle",
     	"esri/layers/MapImageLayer",
     	"dojo/domReady!"
     	], function(Map, MapView,UI, FeatureLayer,Graphic,BasemapToggle,MapImageLayer){  
     	  var view;
     	  var layer = new MapImageLayer({
     		    url: "http://58.213.118.50:6080/arcgis/rest/services/行政边界_新疆/新疆市级行政边界/MapServer/" 
     		  });
     	  var map = new Map({ 
     		  basemap:"dark-gray", 
     		}); 
     	  map.add(layer);
  
  function createView(map) {
       view = new MapView({
        map: map,
        container: "map",
        zoom: 7,  
	    center: [83.261539,43.236485] 
      });
       
  }
createView(map);

var basemapToggle = new BasemapToggle({
	  view: view,  // The view that provides access to the map's "streets" basemap
	  nextBasemap: "hybrid"  // Allows for toggling to the "hybrid" basemap
	});
view.ui.add(basemapToggle, "top-right");


function getSiteInfo(target){
	  var result='';
	  $.ajax({
		  url:'../wetlandManager/findbyid',
		  type:'POST',
		  data:{"id":target.graphic.attributes.ID}, 
		  async:false,
		  success:function(res){
				$('#video').html("");
				$('#video').append("<video style='position: relative;z-index: 10;' src="+res.wlin_video[0]+" type='video/mp4'  autoplay width='100%' height='255px' loop>");	
				var data="<p>行政区划: <span class='value'>"+res.wlin_province+res.wlin_city+res.wlin_district+"</span></p>"
			 	+"<p>湿地面积: <span class='value'>"+res.wlin_official_area+"公顷</span></p>"
			 	+"<p>保护体系: <span class='value'>"+res.wlin_protection_level+"</span></p>"
			 	+"<p>管理单位:<span class='value'>"+res.wlin_management_name+"</span></p>";
			 var src="<p><a href='javascript:showinfo(\""+ target.graphic.attributes.ID + "\")'>查看详情</a></p>"
			  result=data+src; 
		  },
		  error:function(err){
			  return err;
		  } 
	  });
	  return result; 
} 
 
//渲染所有监测点
$.ajax({
	url:'../wetlandManager/calculatecenterandscaleForBD',
	type:'POST',
	success:function(res){
		res.forEach(function(item){
			var point=coordtransform.bd09togcj02(item.wlin_longitude,item.wlin_latitude);	
			var points = coordtransform.gcj02towgs84(point[0], point[1]);
			var polyline = {
					 type: "point",  
					 longitude:points[0].toFixed(6),
					 latitude: points[1].toFixed(6)
			  };
	
			// Create an object for storing attributes related to the line
			 var lineAtt = {
			          名字: item.wlin_name,
			          ID: item.id,				    
			  };
					
					
			 var textSymbol ={
			    	  type: "text",  // autocasts as new TextSymbol()
			    	  color: "white",
			    	  haloColor: "black",
			    	  haloSize: "1px",
			    	  text: item.wlin_name,
			    	  xoffset: 8, 
			    	  yoffset: 10,
			    	  font: {  // autocast as new Font()
			    	    size: 10,
			    	    family: "sans-serif",
			    	    weight: "bolder"
			    	  }
			    };	
	 
			 
			 var polylineGraphic1 = new Graphic({
				geometry: polyline,
			    symbol:{
			    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
					  color: '#FF4040',
					  outline: { // autocasts as new SimpleLineSymbol()
					  color: [255, 255, 255],
					  width: 2
					  }		
			    },
			    attributes: lineAtt,
			    popupTemplate: {  // autocasts as new PopupTemplate()
					title: "{名字}",
			/*		content: [{
					   type: "fields",
					   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
					}]   */
					content:getSiteInfo
				 }
			 });
			 
			
			 
			 var polylineGraphic2 = new Graphic({
					geometry: polyline,
				    symbol: {
				    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
						  color: '#00BFFF',
						  outline: { // autocasts as new SimpleLineSymbol()
						  color: [255, 255, 255],
						  width: 2
						  }		
				    },
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 });
			 var polylineGraphic3 = new Graphic({
					geometry: polyline,
				    symbol: {
				    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
						  color: '#00FF00',
						  outline: { // autocasts as new SimpleLineSymbol()
						  color: [255, 255, 255],
						  width: 2
						  }		
				    },
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 });
			 var polylineGraphic4 = new Graphic({
					geometry: polyline,
				    symbol: {
				    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
						  color: '#00EEEE',
						  outline: { // autocasts as new SimpleLineSymbol()
						  color: [255, 255, 255],
						  width: 2
						  }		
				    },
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 });
			 var polylineGraphic5 = new Graphic({
					geometry: polyline,
				    symbol: {
				    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
						  color: '#B7B7B7',
						  outline: { // autocasts as new SimpleLineSymbol()
							  color: [255, 255, 255],
							  width: 2
						  }
						
				    },
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 });
			 
			 var polylineGraphics = new Graphic({
					geometry: polyline,
				    symbol:textSymbol,
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 }); 
			if(item.wlin_protection_level=='国际重要湿地'){
				view.graphics.add(polylineGraphic1);
			}else if(item.wlin_protection_level=='国家重要湿地'){
				view.graphics.add(polylineGraphic2);
			}else if(item.wlin_protection_level=='一般湿地'){
				view.graphics.add(polylineGraphic3);
			}else if(item.wlin_protection_level=='市级重要湿地'){
				view.graphics.add(polylineGraphic4);
			}else if(item.wlin_protection_level=='省级重要湿地'){
				view.graphics.add(polylineGraphic5);
			}else if(item.wlin_protection_level=='其它'){
				view.graphics.add(polylineGraphic5);
			} 	 	 				 			
			// Add the line graphic to the view's GraphicsLayer
			
			view.on("mouse-wheel", function(evt){
				 // deltaY value is postive when wheel is scrolled up
				 // and it is negative when wheel is scrolled down.
				 console.log(view.zoom);
					if(view.zoom>=10){
						view.graphics.add(polylineGraphics);
					}else if(view.zoom<10){
						view.graphics.remove(polylineGraphics);
					}
				}); 
 
		})
		
	},
	error:function(err){
		console.log(err);
	}
	});  
function showbywetlandname(wetlandname){
	//根据湿地公园名称获取视频监测点数据
	getsitesbywetlandname(wetlandname);
	//根据湿地公园名称进行地图展示
	showmapbywetlandname(wetlandname);
}

	$('#select').on('change',function(){
		var wetland=$(this).val();
		var arr=wetland.split('_');
		showbywetlandname(arr[0]);
	});

	
	/**
	 * 根据湿地公园名称获取视频监测点信息
	 */
	function getsitesbywetlandname(wetlandname) {
		$.ajax({
			url : "../monitoringsite/findsiteinfobywetlandname",
			dataType : "json",
			type : "POST",
			data : {'wetlandname':wetlandname},
			async : false,
			error : function(error) {
				console.log(error.responseText);
				$.gritter.add({
					title : '服务器错误',
					text : '对起，服务器错误，请联系系统管理员！',
					class_name : 'gritter-error'
				});
			},
			success : function(strValue) {
				sites.length = 0;
				for ( var key in strValue) {
					if (strValue[key].show == 1){
						sites.push({
							"longitude" : strValue[key].longitude,
							"latitude" : strValue[key].latitude,
							"id" : key,
							"name" : strValue[key].name,
							"status" : strValue[key].status
						});	
					}
				}
			}
		});
	}

	function showmapbywetlandname(wetlandname) {
		var centerlongitude, centerlatitude, zoom;
		$.ajax({
			url : "../wetlandManager/findbyname",
			dataType : "json",
			type : "POST",
			data : {'name':wetlandname},
			async : false,
			error : function(error) {
				console.log(error.responseText);
				$.gritter.add({
					title : '服务器错误',
					text : '对不起，服务器错误，请联系系统管理员！',
					class_name : 'gritter-error'
				});
			},
			success : function(strValue) {
				centerlongitude = strValue.wlin_longitude;
				centerlatitude = strValue.wlin_latitude;
				view.goTo({
					  center: [centerlongitude, centerlatitude],
					  zoom: 10
					}); 
				 var polyline = {
						 type: "point",  
						 longitude: centerlongitude,
						 latitude: centerlatitude
				  };		
				 var textSymbol ={
				    	  type: "text",  // autocasts as new TextSymbol()
				    	  color: "white",
				    	  haloColor: "black",
				    	  haloSize: "1px",
				    	  text: wetlandname,
				    	  xoffset: 8, 
				    	  yoffset: 10,
				    	  font: {  // autocast as new Font()
				    	    size: 10,
				    	    family: "sans-serif",
				    	    weight: "bolder"
				    	  }
				    };	
				 var polylineGraphics = new Graphic({
						geometry: polyline,
					    symbol:textSymbol						  
					 });
				 view.graphics.add(polylineGraphics);
				 
				 view.on("mouse-wheel", function(evt){
						if(view.zoom<=9){
								view.graphics.remove(polylineGraphics);
							}
						}); 

			}
		});
	}
});



// 启动显示
function showinfo(id) {
	window.location.href='../wetlandManager/indexnew?id='+id;
} 
